package cn.changeforyou.web.cloud.blog.controller;

import cn.changeforyou.web.cloud.blog.entity.po.Article;
import cn.changeforyou.web.cloud.blog.service.ArticleService;
import cn.changeforyou.web.cloud.webBase.controller.AbstractController;
import cn.changeforyou.web.cloud.webBase.common.model.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("articleBack")
public class ArticleBackController  extends AbstractController {

    private ArticleService articleService;

    @PostMapping(value = "/saveOrUpdate")
    public Result saveOrUpdate(@Valid @RequestBody Article article) {
        articleService.saveOrUpdate(article);
        return Result.success();
    }

//    @At(value = "/?", methods = "OPTIONS")
//    @AdaptBy(type = JsonAdaptor.class)
//    @DELETE
//    public NutMap delete(Integer id) {
//        articleService.delete(id);
//        return new NutMap("status", 0);
//    }

    @Autowired
    public void setArticleService(ArticleService articleService) {
        this.articleService = articleService;
    }
}
